package com.dog.basics.admin.controller.common;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.dog.basics.bean.vo.admin.common.SmsLogPageVo;
import com.dog.basics.common.annotation.SysLog;
import com.dog.basics.common.constant.SwaggerConstants;
import com.dog.basics.common.util.PageParam;
import com.dog.basics.common.util.R;
import com.dog.basics.service.common.IDogSmsLogService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;


/**
 * @author dog
 */
@RestController
@RequestMapping("/admin/smsLog")
@Api(value = SwaggerConstants.COMMON+"短信日志模块", tags = SwaggerConstants.COMMON+"短信日志模块")
@AllArgsConstructor
public class PcSmsLogController {

    private final IDogSmsLogService cljgSmsLogService;


    /**
     * @Description:  短信日志模块分页列表
     * @Param:  phone
     * @return:  IPage<SmsLogPageVo>
     * @Author: wph
     * @Date: 2020/3/27 0027
     */
    @ApiOperation(value = "短信日志模块分页列表", notes = "pc:smsLog:page")
    @GetMapping("/page")
    @ApiImplicitParam(name = "phone", value = "手机号", required = false, paramType = "String")
    @PreAuthorize("@pms.hasPermission('pc:smsLog:page')")
    public R<IPage<SmsLogPageVo>> page(PageParam page, String phone) {
        IPage<SmsLogPageVo> smsLogPageDto = cljgSmsLogService.getPageList(page, phone);
        return R.ok(smsLogPageDto);
    }
    /**
     * @Description:  删除短信日志
     * @Param:  ids
     * @return:  Boolean
     * @Author: wph
     * @Date: 2020/3/27 0027
     */
    @SysLog("删除短信日志")
    @ApiOperation(value = "删除短信日志", notes = "pc:smsLog:delete")
    @ApiImplicitParam(value = "短信日志Id", name = "ids", dataType = "List<Long>", required = true)
    @DeleteMapping("/delete")
    @PreAuthorize("@pms.hasPermission('pc:smsLog:delete')")
    public R<Boolean> delete(@RequestParam(value = "ids") List<Long> ids) {
        cljgSmsLogService.deleteObj(ids);
        return R.ok();
    }

}
